package com.talktalk.entity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Session implements Serializable{
	
	public static final int LOGIN_SUCCESS = 1;
	public static final int LOGIN_FAIL = 2;
	public static final int MESSAGE_RECEIVE = 3;
	public static final int MESSAGE_NOT_RECEIVE = 4;
	
	
	private Map<String,Object> map;
	
	public Session() {
		map  = new HashMap<String, Object>();
	}
	
	public Object getObject(String key){
		return map.get(key);
	}
	
	public String getString(String key){
		return (String) map.get(key);
	}
	
	public void put(String key,Object value){
		map.put(key, value);
	}
	
	public void setMessage(Message msg){
		map.put("message", msg);
	}
	
	public Message getMessage(){
		return (Message) map.get("message");
	}
	
	public void setUser(User user){
		map.put("user", user);
	}
	
	public User getUser(){
		return (User) map.get("user");
	}

	public void setErrorMsg(String error){
		map.put("error", error);
	}
	
	public String getErrorMsg(){
		return (String) map.get("error");
	}
	
	public String getAction() {
		return (String) map.get("action");
	}
	
	public void setResponse(int response){
		map.put("response", response);
	}
	
	public int getResponse(){
		return (int) map.get("response");
	}
	
	public void setToken(String token){
		map.put("token", token);
	}
	
	public String getToken(){
		return (String) map.get("token");
	}
	
	public void setFriends(List<?> list){
		map.put("friends", list);
	}
	
	@SuppressWarnings("unchecked")
	public List<Friend> getFriends(){
		return (List<Friend>) map.get("friends");
	}
}
